﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Ecobee.Net
{
	[JsonConverter(typeof(ApiColorConverter))]
	public class ApiColor : ApiObject
	{
		private long _value = 0;

		[JsonIgnore]
		public long Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value= value;
			}
		}

		[JsonIgnore]
		public string HexFormat
		{
			get
			{
				return string.Format("#{0:X8}", this.Value);
			}
		}

		[JsonIgnore]
		public byte[] Bytes
		{
			get
			{
				return BitConverter.GetBytes(this.Value);
			}
		}

		public byte Red
		{
			get
			{
				return this.Bytes[2];
			}
		}

		public byte Green
		{
			get
			{
				return this.Bytes[1];
			}
		}

		public byte Blue
		{
			get
			{
				return this.Bytes[0];
			}
		}

		public static ApiColor Empty
		{
			get
			{
				return new ApiColor();
			}
		}
	}
}
